
package cn.edu.scau.cmi.hombio.service;

import cn.edu.scau.cmi.hombio.domain.CureMethod;
import cn.edu.scau.cmi.hombio.domain.CureTaskMethod;
import cn.edu.scau.cmi.hombio.domain.CureType;

import java.util.List;
import java.util.Set;

import org.junit.Test;

import org.junit.runner.RunWith;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.beans.factory.support.DefaultListableBeanFactory;

import org.springframework.context.ApplicationContext;

import org.springframework.mock.web.MockHttpServletRequest;

import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestExecutionListeners;

import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import org.springframework.test.context.support.DependencyInjectionTestExecutionListener;
import org.springframework.test.context.support.DirtiesContextTestExecutionListener;

import org.springframework.test.context.transaction.TransactionalTestExecutionListener;

import org.springframework.transaction.annotation.Transactional;

import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.RequestScope;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.request.SessionScope;

/**
 * Class to run the service as a JUnit test. Each operation in the service is a separate test.
 *
 */

@RunWith(SpringJUnit4ClassRunner.class)
@TestExecutionListeners({
		DependencyInjectionTestExecutionListener.class,
		DirtiesContextTestExecutionListener.class,
		TransactionalTestExecutionListener.class })
@ContextConfiguration(locations = {
		"file:./resources/pigRs-security-context.xml",
		"file:./resources/pigRs-service-context.xml",
		"file:./resources/pigRs-dao-context.xml",
		"file:./resources/pigRs-web-context.xml" })
@Transactional
public class CureTypeServiceTest {

	/**
	 * The Spring application context.
	 *
	 */
	@SuppressWarnings("unused")
	private ApplicationContext context;

	/**
	 * The service being tested, injected by Spring.
	 *
	 */
	@Autowired
	protected CureTypeService service;

	/**
	 * Instantiates a new CureTypeServiceTest.
	 *
	 */
	public CureTypeServiceTest() {
		setupRequestContext();
	}

	/**
	 * Operation Unit Test
	 */
	@Test
	public void findCureTypeByPrimaryKey() {
		// TODO: JUnit - Populate test inputs for operation: findCureTypeByPrimaryKey 
		Integer id = 0;
		CureType response = null;
		response = service.findCureTypeByPrimaryKey(id);
		// TODO: JUnit - Add assertions to test outputs of operation: findCureTypeByPrimaryKey
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureTaskMethod entity
	* 
	 */
	@Test
	public void deleteCureTypeCureTaskMethods() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureTypeCureTaskMethods 
		Integer curetype_id = 0;
		Integer related_curetaskmethods_id = 0;
		CureType response = null;
		response = service.deleteCureTypeCureTaskMethods(curetype_id, related_curetaskmethods_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureTypeCureTaskMethods
	}

	/**
	 * Operation Unit Test
	* Save an existing CureTaskMethod entity
	* 
	 */
	@Test
	public void saveCureTypeCureTaskMethods() {
		// TODO: JUnit - Populate test inputs for operation: saveCureTypeCureTaskMethods 
		Integer id_1 = 0;
		CureTaskMethod related_curetaskmethods = new cn.edu.scau.cmi.hombio.domain.CureTaskMethod();
		CureType response = null;
		response = service.saveCureTypeCureTaskMethods(id_1, related_curetaskmethods);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureTypeCureTaskMethods
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureType entity
	* 
	 */
	@Test
	public void deleteCureType() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureType 
		CureType curetype = new cn.edu.scau.cmi.hombio.domain.CureType();
		service.deleteCureType(curetype);
	}

	/**
	 * Operation Unit Test
	* Return a count of all CureType entity
	* 
	 */
	@Test
	public void countCureTypes() {
		Integer response = null;
		response = service.countCureTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: countCureTypes
	}

	/**
	 * Operation Unit Test
	* Load an existing CureType entity
	* 
	 */
	@Test
	public void loadCureTypes() {
		Set<CureType> response = null;
		response = service.loadCureTypes();
		// TODO: JUnit - Add assertions to test outputs of operation: loadCureTypes
	}

	/**
	 * Operation Unit Test
	* Delete an existing CureMethod entity
	* 
	 */
	@Test
	public void deleteCureTypeCureMethods() {
		// TODO: JUnit - Populate test inputs for operation: deleteCureTypeCureMethods 
		Integer curetype_id_1 = 0;
		Integer related_curemethods_id = 0;
		CureType response = null;
		response = service.deleteCureTypeCureMethods(curetype_id_1, related_curemethods_id);
		// TODO: JUnit - Add assertions to test outputs of operation: deleteCureTypeCureMethods
	}

	/**
	 * Operation Unit Test
	* Save an existing CureMethod entity
	* 
	 */
	@Test
	public void saveCureTypeCureMethods() {
		// TODO: JUnit - Populate test inputs for operation: saveCureTypeCureMethods 
		Integer id_2 = 0;
		CureMethod related_curemethods = new cn.edu.scau.cmi.hombio.domain.CureMethod();
		CureType response = null;
		response = service.saveCureTypeCureMethods(id_2, related_curemethods);
		// TODO: JUnit - Add assertions to test outputs of operation: saveCureTypeCureMethods
	}

	/**
	 * Operation Unit Test
	* Return all CureType entity
	* 
	 */
	@Test
	public void findAllCureTypes() {
		// TODO: JUnit - Populate test inputs for operation: findAllCureTypes 
		Integer startResult = 0;
		Integer maxRows = 0;
		List<CureType> response = null;
		response = service.findAllCureTypes(startResult, maxRows);
		// TODO: JUnit - Add assertions to test outputs of operation: findAllCureTypes
	}

	/**
	 * Operation Unit Test
	* Save an existing CureType entity
	* 
	 */
	@Test
	public void saveCureType() {
		// TODO: JUnit - Populate test inputs for operation: saveCureType 
		CureType curetype_1 = new cn.edu.scau.cmi.hombio.domain.CureType();
		service.saveCureType(curetype_1);
	}

	/**
	 * Autowired to set the Spring application context.
	 *
	 */
	@Autowired
	public void setContext(ApplicationContext context) {
		this.context = context;
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("session", new SessionScope());
		((DefaultListableBeanFactory) context.getAutowireCapableBeanFactory()).registerScope("request", new RequestScope());
	}

	/**
	 * Sets Up the Request context
	 *
	 */
	private void setupRequestContext() {
		MockHttpServletRequest request = new MockHttpServletRequest();
		ServletRequestAttributes attributes = new ServletRequestAttributes(request);
		RequestContextHolder.setRequestAttributes(attributes);
	}
}
